<?php
	include "../controller/ConectBanco.php";
    include "../controller/Sessao.php";
	
	if($_SESSION["login"] != "admin"){
		header("location:../view/Principal.php");
	}
	
	$idstatus = $_GET['idStatus'];
	
	$queryStatus = mysql_query("SELECT * FROM status WHERE idStatus = $idstatus")or die(mysql_error());
	$arrayStatus = mysql_fetch_array($queryStatus);
?>	

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="UTF-8" />
        <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  -->
        <title>Editar Package Status</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <meta name="description" content="Login and Registration Form with HTML5 and CSS3" />
        <meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" />
        <meta name="author" content="Codrops" />
        <link rel="shortcut icon" href="../favicon.ico"> 
        <link rel="stylesheet" type="text/css" href="../css/demo.css" />
        <link rel="stylesheet" type="text/css" href="../css/style.css" />
		
    </head>
    <body>
        <div class="container">
			<?php
				include "MenuAdmin.php";
				Menu::data();
				Menu::menuAdmin(); 
			?>
            <header>
                <h1>LOCALIZAGORA<span></br>Sistema de rastreamento via satelite </span></h1>
				
            </header>
            <section>				
                <div id="container_demo" >
                    <!-- hidden anchor to stop jump http://www.css3create.com/Astuce-Empecher-le-scroll-avec-l-utilisation-de-target#wrap4  -->
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  action="../controller/Editar.php?idStatus=<?php echo $idstatus;?>" method="post" autocomplete="on" > 
                                <h1>Editar Package Status</h1> 
								<p> 
									<label for="nome" class="nome"  > ID : </label> <?php echo $arrayStatus['idStatus'];?><br>
									<label for="nome" class="nome"  > ID Device: </label> <?php echo $arrayStatus['idDevice'];?>
									 <input id="iddevice" name="iddevice" required="required" value="<?php echo $arrayStatus['idDevice'];?>" type="hidden" />
                                  
                                </p>
                                <p> 
									<label for="combustEletric" class="combustEletric"  > combustEletric </label>
                                    <select name="combustEletric" required="required">
										<?php 
												if($arrayStatus['combustEletric'] == 0){
													echo "<option value=\"0\" selected >On</option>
													     <option value=\"1\" >Off</option>";
													
												}else{
													echo "<option value=\"0\" >On</option>
													      <option value=\"1\" selected  >Off</option>";
												}									
										?>
									</select>
                                </p>
                                <p> 
									<label for="tracking" class="tracking"  > Tracking </label>
                                    <select name="tracking" required="required">
										<?php 
											if($arrayStatus['tracking'] == 1){
												echo "<option value=\"1\" selected >On</option>
													    <option value=\"0\" >Off</option>";
	
											}else{
												echo "<option value=\"1\" >On</option>
												      <option value=\"0\" selected  >Off</option>";
											}
										?>
									</select>
                                </p>
								<p> 
									<label for="alarm" class="alarm"  > Alarm </label>
                                    <select name="alarm" required="required">
										<?php 
												$typeStatus = array('Normal','Shock','Power cut','Low battery','SOS');
												foreach($typeStatus as  $i => $tipo){
													if($arrayStatus['alarm'] == $i){
														echo "<option value=\"$i\" select =\"selected\">$tipo</option>";
													}else{
														echo "<option value=\"$i\" >$tipo</option>";
													}
												}
															
										?>
									</select>
                                </p>
								<p> 
									<label for="charge" class="charge"  > Charge </label>
                                    <select name="charge" required="required">
										<?php 
											if($arrayStatus['charge'] == 1){
												echo "<option value=\"1\" selected >On</option>
													    <option value=\"0\" >Off</option>";

											}else{
												echo "<option value=\"1\" >On</option>
													 <option value=\"0\" selected  >Off</option>";
											}
													
										?>
									</select>
                                </p>
								<p> 
									<label for="acc" class="acc"  > ACC </label>
                                    <select name="acc" required="required">
										<?php 
											if($arrayStatus['acc'] == 1){
												echo "<option value=\"1\" selected >On</option>
													   <option value=\"0\" >Off</option>";

												}else{
													echo "<option value=\"1\" >On</option>
													      <option value=\"0\" selected  >Off</option>";
												}
		
										?>
									</select>
                                </p>
								<p> 
									<label for="voltage" class="voltage"  > Voltage </label>
                                    <select name="voltage" required="required">
										<?php 
												$typeVoltage = array('No power','Extreme Low','Very Low','Low Battery','Medium','High','Very high');
												foreach($typeVoltage as  $i => $tipo){
													if($arrayStatus['voltage'] == $i){
														echo "<option value=\"$i\" selected>$tipo</option>";
													}else{
														echo "<option value=\"$i\" >$tipo</option>";
													}
												}
															
										?>
									</select>
                                </p>
								<p> 
									<label for="signal" class="signal"  > Signal :  </label>
                                    <input id="signal" name="signal" required="required" value="<?php echo $arrayStatus['signal'];?>" type="number" placeholder="xx%"/>
                                </p>
								<p> 
									<label for="dateTime" class="dateTime"  > Hora Sistema </label>
									<input id="dateTime" name="dateTime" required="required" value="<?php echo $arrayStatus['dateTime'];?>" type="text" placeholder="xxxx-xx-xx xx:xx:xx"/>
                                </p>
								<p> 
									<label for="realDateTime" class="realDateTime"  > Hora Device </label>
									<input id="realDateTime" name="realDateTime"  value="<?php echo $arrayStatus['realDateTime'];?>" type="text" placeholder="xxxx-xx-xx xx:xx:xx"/>
                                </p>
                               <br><br>
                                <p class="button"> 
                                    <input type="submit" value="Salva" /> 
								</p>
                            </form>
                        </div>

                        
						
                    </div>
                </div>  
            </section>
        </div>
    </body>
</html>